package com.wenli.graduate2022.wenliGreenShop.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @author HuangHai
 * @date 2021/10/13 10:16
 */
@Data
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler" })
public class Review implements Serializable {
    private Integer reviewId;
    private String reviewContent;     //评论内容
    @Getter(AccessLevel.NONE)
    private Date reviewCreatedate;    //评论日期
    private User reviewUser;        //哪个用户的评论
    private Product reviewProduct;   //关联的哪个产品
    private ProductOrderItem reviewOrderItem;  //关联订单项

    public String getReviewCreatedate() {
        if (reviewCreatedate != null) {
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd", Locale.UK);
            return time.format(reviewCreatedate);
        }
        return null;
    }
}
